<?php

defined('_JEXEC') or die;

class modBakery_CategoryHelper
{
	static function loadCategories()
	{
		$categories = JCategories::getInstance('bakerys');
		$category = $categories->get('root');
		
		if ($category != null)
		{
			$items = $category->getChildren();
			return $items;
		}
		
		/*
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select("*")
			->from("#__categories")
			->where("extension = 'com_bakerys' and published = 1");
		$db->setQuery($query);
		return $db->loadObjectList();*/	
	} 
	
	static function loadOneLocation()
	{
		$db = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select("*")
			->from("#__bakery_locations")
			->where("state = 1");
		$db->setQuery($query,0,1);
		return $db->loadObject();
	}
}
